package com.wyh.controller;


import com.wyh.common.annotation.Log;
import com.wyh.common.annotation.RateLimiter;
import com.wyh.common.enums.BusinessType;
import com.wyh.common.response.PageInfo;
import com.wyh.common.result.R;
import com.wyh.common.util.ExcelUtils;
import com.wyh.entity.MsgVerifyMessage;
import com.wyh.request.AddChatRoomVerifyMessageRequest;
import com.wyh.request.AddFriendVerifyMessageRequest;
import com.wyh.request.MsgVerifyMessageRequest;
import com.wyh.service.IMsgVerifyMessageService;
import com.wyh.vo.AddFriendVo;
import com.wyh.vo.VerifyMessageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;

/**
 * 【请填写功能名称】控制层
 *
 * @author WangYuHang
 * @date 2024-03-08
 */
@Slf4j
@AllArgsConstructor
@RestController
@Api(value = "【请填写功能名称】接口管理",tags = "【请填写功能名称】接口管理")
@RequestMapping("/admin/msgVerifyMessage" )
public class MsgVerifyMessageController {

    private final IMsgVerifyMessageService iMsgVerifyMessageService;


    /**
     * 添加好友申请验证消息
     */
    @ApiOperation(value = "添加好友申请消息")
    @PostMapping("addFriend")
    public R<String> addFriend(@RequestBody AddFriendVerifyMessageRequest addFriendVerifyMessageRequest){
        R<String> stringR = iMsgVerifyMessageService.addFriendVerifyMessage(addFriendVerifyMessageRequest);
        return stringR;
    }
    /**
     * 添加群聊申请验证消息
     */
    @ApiOperation(value = "添加群聊申请消息")
    @PostMapping("addChatRoom")
    public R<String> addChatRoom(@RequestBody AddChatRoomVerifyMessageRequest addChatRoomVerifyMessageRequest){
        R<String> stringR = iMsgVerifyMessageService.addChatRoomVerifyMessage(addChatRoomVerifyMessageRequest);
        return stringR;
    }

    /**
     * 处理验证消息
     */
    @ApiOperation("处理验证信息")
    @PostMapping("/dispose")
    public R<String> disposeVerifyMessage(@RequestBody MsgVerifyMessageRequest msgVerifyMessageRequest){
        R<List<VerifyMessageVo>> verifyMessage = iMsgVerifyMessageService.getVerifyMessage();
        return null;
    }



    /**
     * 获取验证消息
     */
    @ApiOperation("获取验证信息")
    @GetMapping
    public R<List<VerifyMessageVo>> getVerifyMessage(){
        R<List<VerifyMessageVo>> verifyMessage = iMsgVerifyMessageService.getVerifyMessage();
        return verifyMessage;
    }

    /**
     * 分页查询【请填写功能名称】列表
     */
    @ApiOperation(value = "分页查询【请填写功能名称】列表")
    @PostMapping("/pageList")
    public R<PageInfo<MsgVerifyMessage>> pageList(@RequestBody MsgVerifyMessageRequest msgVerifyMessageRequest) {
        return R.success(iMsgVerifyMessageService.pageList(msgVerifyMessageRequest));
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @ApiOperation(value = "获取【请填写功能名称】详细信息")
    @GetMapping(value = "/query/{id}")
    public R<MsgVerifyMessage> detail(@PathVariable("id") Integer id) {
        return R.success(iMsgVerifyMessageService.getById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @Log(title = "新增【请填写功能名称】", businessType = BusinessType.INSERT)
    @RateLimiter
    @ApiOperation(value = "新增【请填写功能名称】")
    @PostMapping("/add")
    public R<Void> add(@RequestBody MsgVerifyMessageRequest msgVerifyMessageRequest) {
        iMsgVerifyMessageService.add(msgVerifyMessageRequest);
        return R.success();
    }

    /**
     * 修改【请填写功能名称】
     */
    @Log(title = "修改【请填写功能名称】", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "修改【请填写功能名称】")
    @PostMapping("/update")
    public R<Void> edit(@RequestBody MsgVerifyMessageRequest msgVerifyMessageRequest) {
        iMsgVerifyMessageService.update(msgVerifyMessageRequest);
        return R.success();
    }

    /**
     * 删除【请填写功能名称】
     */
    @Log(title = "删除【请填写功能名称】", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除【请填写功能名称】")
    @PostMapping("/delete/{ids}")
    public R<Void> remove(@PathVariable Integer[] ids) {
        iMsgVerifyMessageService.deleteBatch(Arrays.asList(ids));
        return R.success();
    }

    /**
    * 导出【请填写功能名称】
    *
    * @param response response
    * @throws IOException IOException
    */
    @PostMapping(value = "/export")
    public void exportExcel(HttpServletResponse response,@RequestBody MsgVerifyMessageRequest msgVerifyMessageRequest) throws IOException {
        List<MsgVerifyMessage> list = iMsgVerifyMessageService.list(msgVerifyMessageRequest);
        ExcelUtils.exportExcel(list, MsgVerifyMessage.class, "【请填写功能名称】信息", response);
    }
}
